package com.hertz.iris.view.alert;

import java.util.List;

import android.os.Bundle;
import android.support.v4.content.Loader;

import com.github.kevinsawicki.wishlist.SingleTypeAdapter;
import com.hertz.iris.R;
import com.hertz.iris.pojo.ResponseIsAlert;
import com.hertz.iris.ui.ItemListFragment;
import com.hertz.iris.ui.ThrowableLoader;
import com.hertz.iris.util.BundleKeys;

public class MatchAlarmAlertFragment extends ItemListFragment<ResponseIsAlert> {
	
	List<ResponseIsAlert> alertAlarms;

	@Override
    public Loader<List<ResponseIsAlert>> onCreateLoader(int id, Bundle args) {
        final List<ResponseIsAlert> initialItems = items;
        return new ThrowableLoader<List<ResponseIsAlert>>(getActivity(), items) {

            @Override
            public List<ResponseIsAlert> loadData() throws Exception {
            	Bundle bundle = getActivity().getIntent().getExtras();
                return (List<ResponseIsAlert>)bundle.getSerializable(BundleKeys.MatchAlarmBundleKeys.MATCH_ALARM_ALERT_KEY);
            }
        };
    }
	@Override
    protected int getErrorMessage(Exception exception) {
        return R.string.error_loading_matchs;
    }

	@Override
    protected SingleTypeAdapter<ResponseIsAlert> createAdapter(List<ResponseIsAlert> items) {
        return new MatchAlarmAlertListAdapter(getActivity().getLayoutInflater(), items);
    }
}
